package com.getinstaliker.screen.common;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;

import com.getinstaliker.screen.GetCoinsFragment;
import com.getinstaliker.screen.GetLikesFragment;
import com.getinstaliker.screen.LoginFragment;
import com.getinstaliker.screen.SpendFragment;
import com.instagram.getinstaliker.R;

/**
 * The Class GetInstalikerHeaderBar.
 */
public class GetInstalikerHeaderBar extends SimpleHeaderBar implements OnClickListener{

	/**
	 * Instantiates a new gets the instaliker header bar.
	 *
	 * @param act the act
	 * @param frag the frag
	 */
	public GetInstalikerHeaderBar(FragmentActivity act,Fragment frag) {
		super(act,frag);
	}

	/* (non-Javadoc)
	 * @see com.getinstaliker.screen.common.SimpleHeaderBar#setSubMenu()
	 */
	@Override
	protected void setSubMenu() {
		if(mFrag instanceof LoginFragment){
			mBtnBack.setVisibility(View.VISIBLE);
			mBtnBack.setOnClickListener(this);
		}else if(mFrag instanceof SpendFragment){
			mBtnBack.setVisibility(View.VISIBLE);
			mTvBack.setText(mFragActivity.getResources().getString(R.string.get_likes));
			mTvNumCoins.setVisibility(View.VISIBLE);
			mBtnBack.setOnClickListener(this);
		}else if(mFrag instanceof GetCoinsFragment || mFrag instanceof GetLikesFragment){
			mBtnReload.setVisibility(View.VISIBLE);
			mTvNumCoins.setVisibility(View.VISIBLE);
			mBtnReload.setOnClickListener(this);
		}
		
	}

	/* (non-Javadoc)
	 * @see android.view.View.OnClickListener#onClick(android.view.View)
	 */
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnBack:
			if(mFrag instanceof BaseGetInstalikerHeaderFragment){
				((BaseGetInstalikerHeaderFragment)mFrag).onBack();
			}
			break;
		case R.id.btnReload:
			if(mFrag instanceof BaseGetInstalikerHeaderFragment){
				((BaseGetInstalikerHeaderFragment)mFrag).onReload();
			}
			break;
		case R.id.btnRightReload:
			if(mFrag instanceof BaseGetInstalikerHeaderFragment){
				((BaseGetInstalikerHeaderFragment)mFrag).onReload();
			}
			break;
		default:
			break;
		}
	}

}
